﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.Services.Transaction;
using NHibernate;

namespace BEGDC.PreContract.BLL
{
    [Transactional]
    public partial class ProblemLVAssignment : IProblemLVAssignment
    {
        private ISessionFactory factory;

        /// <summary>
        /// Initiate session factory.
        /// </summary>
        /// <param name="sessionFactory"></param>
        public ProblemLVAssignment(ISessionFactory sessionFactory)
        {
            this.factory = sessionFactory;
        }

        //Get by id
        [Transaction(TransactionMode.Requires)]
        public BEGDC.PreContract.DAL.ProblemLVAssignment GetProblemLVAssignment(int id)
        {
            BEGDC.PreContract.DAL.ProblemLVAssignment problemLVAssignment = BEGDC.PreContract.DAL.ProblemLVAssignment.TryFind(id);
            return problemLVAssignment;
        }

        [Transaction(TransactionMode.Requires)]
        public int AddProblemLVAssignment(BEGDC.PreContract.DAL.DicItem problemLV1ID, BEGDC.PreContract.DAL.DicItem problemLV2ID)
        {
            try
            {
                BEGDC.PreContract.DAL.ProblemLVAssignment problemLVAssignment = new BEGDC.PreContract.DAL.ProblemLVAssignment();
                problemLVAssignment.ProblemLV1ID = problemLV1ID;
                problemLVAssignment.ProblemLV2ID = problemLV2ID;

                return problemLVAssignment.ID;
            }
            catch (Exception ex)
            {
                throw new BEGDC.Utility.ExceptionManagement.GDCException("ProblemLVAssignment", string.Format("Error occured when adding a new ProblemLVAssignment, error information: {0}.", ex.Message), ex);
            }
        }



    }
}
